package com.collectplus.express.model;

import java.io.Serializable;
import java.util.HashSet;

import droid.frame.utils.lang.Str;
import droid.frame.utils.sqlite.annotation.Column;

/**
 * 收件人
 *
 * @author coffee<br>
 * 2015-8-3上午9:33:21
 */
public class ReceiverBean implements Serializable {
    /**
     *
     */
    private static final long serialVersionUID = 5528353713043717249L;

    private int id; // 收件人ID, 当下单成功后, id与parcelId均是包裹ID
    private int parcelId;// 包裹ID
    private String name;// ...姓名
    private String phone; // ...电话
    private String address;// ...详细地区
    @Column(name = "comment")
    private String remark; // ...备注

    private String province;// 收件人省
    private String city;// ...市
    private String district;// ...区

    private String provinceId;// 收件人区域编码[省]
    private String cityId; // ...市
    private String districtId;// ...区

    private String buildName = "";//建筑物名字
    private String goodsImageOld;// 保存的上一次提交的图片
    private String goodsImage; // 要寄得东西的图片

    private String parcelImgUrl;// 网络图片
    @Column(name = "parcelName")
    private String goodsName; // 寄的东西的名称
    @Column(name = "parcelValue")
    private String goodsValue;// 寄的东西的价值

    private String expressCompanyId; // 快递公司ID
    private String expressCompanyName;// 快递公司名称
    private String expressPrice;

    private String senderProvinceId = "110000"; // 发件人城市Id(默认 [北京])

    private String cost;
    private String weight;
    private String currentRouter;
    private long createTime;
    private String status;
    /**
     * 0 标准寄件; 1 投递袋自助; 2 投递袋上门 ， 3驿站  6上门寄件方式 <br>
     */
    private int type = 0; // add 2016-9-26
    /**
     * 投递袋的二维码
     */
    private BagBean bag;
    /**
     * 投递点柜子信息
     */
    private ServicePointBean servicePoint;
    // coffee add 11.09 寄件人信息
    private SenderBean sender;
    //保存选择备注的集合
    private HashSet<Integer> remarkSelected = null;

    /**
     * 上门地址相关信息对象
     */
    private VisitDoorBean visitDoorBean;

    //
    public ReceiverBean() {

    }

    public ReceiverBean(int type) {
        this.type = type;
    }

    public void copyReceiver(ReceiverBean item) {
        if (item == null) {
            return;
        }
        this.setId(item.getId());
        this.setName(item.getName());
        this.setPhone(item.getPhone());
        this.setAddress(item.getAddress());
    }

    /**
     * 设置区域相关的属性
     */
    public void copyRegion(ReceiverBean item) {
        if (item == null) {
            return;
        }
        this.setProvince(item.getProvince());
        this.setProvinceId(item.getProvinceId());
        this.setCity(item.getCity());
        this.setCityId(item.getCityId());
        this.setDistrict(item.getDistrict());
        this.setDistrictId(item.getDistrictId());
        this.setAddress(item.getAddress()+item.getBuildName());
        this.setBuildName(item.getBuildName());
    }

    /**
     * 判断图片是否被修改<br>
     *
     * @return
     */
    public boolean isModifyImage() {
        // 没有网络图片、即图片都是本地的
        if (Str.isEmpty(parcelImgUrl)) {
            // 此时，图片被修改只有一种情况
            if (Str.isNotEmpty(goodsImage) && Str.isNotEmpty(goodsImageOld) && goodsImageOld.equals(goodsImage) == false) {
                return true;
            } else {
                return false;
            }
        } else {
            // 有网络图片--(此时本地的图片路径被重置 -- 只要goodsImage和goodsImageOld不相等,则认为被修改)
            if (Str.isNotEmpty(goodsImage) && Str.isNotEmpty(goodsImageOld) && goodsImage.equals(goodsImageOld) == false) {
                return true;
            } else {
                return false;
            }
        }
    }

    /**
     * 是否上门标准寄件
     *
     * @return
     */
    public boolean isGoHomeStandard() {
        return type == 0;
    }

    /**
     * 上门有投递袋
     *
     * @return
     */
    public boolean isGoHomeHasBag() {
        return type == 2;
    }

    /**
     * 自助寄件 、有投递袋 (智能柜、驿站)
     *
     * @return
     */
    public boolean isSelfServiceHasBag() {
        // (servicePoint != null && servicePoint.getPostStationType() == 1)//智能柜
        return type == 1;
    }

    public String getImageUrl() {
        if (Str.isNotEmpty(getGoodsImage())) {
            return getGoodsImage();
        }
        // 从网络而加载
        else if (Str.isNotEmpty(getParcelImgUrl())) {
            return getParcelImgUrl();
        }
        return "";
    }

    // /

    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    public int getParcelId() {
        return parcelId;
    }

    public void setParcelId(int parcelId) {
        this.parcelId = parcelId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getAddress() {
        return address;
    }

    public void setAddress(String address) {
        this.address = address;
    }

    public String getRemark() {
        if (remark == null) {
            remark = "";
        }
        return remark;
    }

    public void setRemark(String remark) {
        this.remark = remark;
    }

    public String getProvince() {
        if (province == null) {
            province = "";
        }
        return province;
    }

    public void setProvince(String province) {
        this.province = province;
    }

    public String getCity() {
        if (city == null) {
            city = "";
        }
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getDistrict() {
        if (district == null) {
            district = "";
        }
        return district;
    }

    public void setDistrict(String district) {
        this.district = district;
    }

    public String getCityId() {
        return cityId;
    }

    public void setCityId(String cityId) {
        this.cityId = cityId;
    }

    public String getDistrictId() {
        return districtId;
    }

    public void setDistrictId(String districtId) {
        this.districtId = districtId;
    }

    public String getProvinceId() {
        return provinceId;
    }

    public void setProvinceId(String provinceId) {
        this.provinceId = provinceId;
    }

    public String getExpressCompanyName() {
        return expressCompanyName;
    }

    public void setExpressCompanyName(String expressCompanyName) {
        this.expressCompanyName = expressCompanyName;
    }

    public String getExpressCompanyId() {
        return expressCompanyId;
    }

    public void setExpressCompanyId(String expressCompanyId) {
        this.expressCompanyId = expressCompanyId;
    }

    public String getExpressPrice() {
        return expressPrice;
    }

    public void setExpressPrice(String expressPrice) {
        this.expressPrice = expressPrice;
    }

    public String getCost() {
        return cost;
    }

    public void setCost(String cost) {
        this.cost = cost;
    }

    public String getWeight() {
        return weight;
    }

    public void setWeight(String weight) {
        this.weight = weight;
    }

    public String getCurrentRouter() {
        return currentRouter;
    }

    public void setCurrentRouter(String currentRouter) {
        this.currentRouter = currentRouter;
    }

    public long getCreateTime() {
        return createTime;
    }

    public void setCreateTime(long createTime) {
        this.createTime = createTime;
    }

    public String getStatus() {
        return status;
    }

    public void setStatus(String status) {
        this.status = status;
    }

    public static long getSerialversionuid() {
        return serialVersionUID;
    }

    public String getSenderProvinceId() {
        return senderProvinceId;
    }

    public void setSenderProvinceId(String senderProvinceId) {
        this.senderProvinceId = senderProvinceId;
    }

    public String getGoodsImageOld() {
        return goodsImageOld;
    }

    public void setGoodsImageOld(String goodsImageOld) {
        this.goodsImageOld = goodsImageOld;
    }

    public String getGoodsImage() {
        if (goodsImage == null) {
            goodsImage = "";
        }
        return goodsImage;
    }

    public void setGoodsImage(String goodsImage) {
        this.goodsImage = goodsImage;
    }

    public String getGoodsName() {
        if (goodsName == null) {
            goodsName = "";
        }
        return goodsName;
    }

    public void setGoodsName(String goodsName) {
        this.goodsName = goodsName;
    }

    public String getGoodsValue() {
        if (goodsValue == null) {
            goodsValue = "";
        }
        return goodsValue;
    }

    public void setGoodsValue(String goodsValue) {
        this.goodsValue = goodsValue;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public BagBean getBag() {
        return bag;
    }

    public void setBag(BagBean bag) {
        this.bag = bag;
    }

    public ServicePointBean getServicePoint() {
        return servicePoint;
    }

    public void setServicePoint(ServicePointBean servicePoint) {
        this.servicePoint = servicePoint;
    }

    public SenderBean getSender() {
        return sender;
    }

    public void setSender(SenderBean sender) {
        this.sender = sender;
    }

    public String getParcelImgUrl() {
        return parcelImgUrl;
    }

    public void setParcelImgUrl(String parcelImgUrl) {
        this.parcelImgUrl = parcelImgUrl;
    }

    public VisitDoorBean getVisitDoorBean() {
        return visitDoorBean;
    }

    public void setVisitDoorBean(VisitDoorBean visitDoorBean) {
        this.visitDoorBean = visitDoorBean;
    }

    public HashSet<Integer> getRemarkSelected() {
        return remarkSelected == null ? new HashSet<Integer>() : remarkSelected;
    }

    public void setRemarkSelected(HashSet<Integer> remarkSelected) {
        this.remarkSelected = remarkSelected;
    }

    public String getBuildName() {
        return buildName;
    }

    public void setBuildName(String buildName) {
        this.buildName = buildName;
    }
}
